package com.seeyon.apps.seepkk.manager;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import www.seeyon.com.utils.StringUtil;

import com.alibaba.fastjson.JSONObject;
import com.seeyon.apps.kk.constants.Constants;
import com.seeyon.apps.kk.manager.FormDataBaseManager;
import com.seeyon.apps.seepkk.dao.SeepDao;
import com.seeyon.cap4.form.api.FormApi4Cap4;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.cap4.form.bean.FormDataSubBean;
import com.seeyon.cap4.form.bean.FormFieldBean;
import com.seeyon.cap4.form.bean.FormTableBean;
import com.seeyon.cap4.form.bean.fieldCtrl.WordInjectionCtrl;
import com.seeyon.cap4.form.modules.engin.businessRelation.CAP4FormBusinessRelationDAO;
import com.seeyon.cap4.form.modules.engin.businessRelation.CAP4FormBusinessRelationManager;
import com.seeyon.cap4.form.modules.engin.relation.CAP4FormRelationRecordDAO;
import com.seeyon.cap4.form.po.CAPFormBusinessRelation;
import com.seeyon.cap4.form.po.CAPFormRelationRecord;
import com.seeyon.ctp.common.ctpenumnew.manager.EnumManager;
import com.seeyon.ctp.common.exceptions.BusinessException;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumBean;
import com.seeyon.ctp.common.po.ctpenumnew.CtpEnumItem;
import com.seeyon.ctp.organization.manager.OrgManager;
import com.seeyon.ctp.util.ParamUtil;
import com.seeyon.ctp.util.Strings;
import com.seeyon.ctp.util.annotation.AjaxAccess;
import com.seeyon.ctp.util.json.JSONUtil;

public class QiangsSeepManagerImpl implements QiangsSeepManager {

	private static final Log log = LogFactory.getLog(QiangsSeepManagerImpl.class);
	private SeepDao seepDao;
	private OrgManager orgManager;
	private FormApi4Cap4 formApi4Cap4;
	private EnumManager enumManagerNew;
//	private FormDataBaseManager kkBaseFormManager;
	private CAP4FormRelationRecordDAO cap4FormRelationRecordDAO;
	private CAP4FormBusinessRelationDAO cap4FormBusinessRelationDAO;
	private CAP4FormBusinessRelationManager cap4FormBusinessRelationManager;
	
	/*@Override
	@AjaxAccess
	public List<Map> getTreeDate(String enumName, String selects, int showLevel) {
		// TODO Auto-generated method stub
		List<Map> mapList = new ArrayList<Map>();
		try{
			CtpEnumBean bean = getCtpEnumBeanByName(enumName);
			if(bean == null) {
				return mapList;
			}
			List<CtpEnumItem> list = enumManagerNew.getEmumItemByEmumId(bean.getId());
			if(0 == showLevel){
				selects = getParentEnum(list, selects);
			} else if(1 == showLevel){//选中顶层
				selects = getChildEnum(list, selects);
			}
			for(CtpEnumItem items : list) {
				if(items.getState() == 0) continue;
				Map<String, Object> map = new HashMap<String, Object>();
				map.put("id", items.getId().toString());
				map.put("name", items.getShowvalue());
				map.put("pid", items.getParentId().toString());
				map.put("checked", false);
				map.put("open", false);
				if(Strings.isNotEmpty(selects)){
					if(selects.contains(ParamUtil.getString(map, "id"))){
						map.put("checked", true);
						map.put("open", true);
					}
				}
				if(items.getParentId().equals(0L)){
					map.put("isTop", true);
				} else {
					map.put("isTop", false);
				}
				if(enumManagerNew.hasEnumChildren(items.getId())){
					map.put("isBotton", true);
				} else {
					List<CtpEnumItem> its = enumManagerNew.getChildEnumItems(items.getId());
					if(CollectionUtils.isEmpty(its)){
						map.put("isBotton", true);
					} else {
						map.put("isBotton", false);
					}
				}
				mapList.add(map);
			}
			return mapList;
		} catch (BusinessException e) {
			// TODO Auto-generated catch block
			log.error("##强生客开: ", e);
		}
		return mapList;
	}
	
	private String getParentEnum(List<CtpEnumItem> list, String ids){
		if(Strings.isNotEmpty(ids)){
			for(CtpEnumItem item : list){
				if(ids.contains(item.getId().toString())
						&& !ids.contains(item.getParentId().toString())){
					ids += "," + item.getParentId().toString();
					ids = getParentEnum(list, ids);
				}
			}
		}
		return ids;
	}
	
	private String getChildEnum(List<CtpEnumItem> list, String ids){
		if(Strings.isNotEmpty(ids)){
			for(CtpEnumItem item : list){
				if(ids.contains(item.getParentId().toString())
						&& !ids.contains(item.getId().toString())
						&& !item.getParentId().equals(0L)){
					ids += "," + item.getId().toString();
					ids = getChildEnum(list, ids);
				}
			}
		}
		return ids;
	}

	private CtpEnumBean getCtpEnumBeanByName(String name){
		try {
			List<CtpEnumBean> item = enumManagerNew.getAllOrgCtpEnum(Constants.DEFAULT_ACCOUNT_ID);
			for(CtpEnumBean bean : item){
				if(name.equals(bean.getEnumname())){
					return bean;
				}
			}
		} catch (BusinessException e) {
			// TODO Auto-generated catch block
			log.error("##强生客开: ", e);
		}
		return null;
	}*/
	
	@Override
	@AjaxAccess
	public String getEnumShowValue(String ids){
//		List<String> list = Arrays.asList(ids.split(","));
		String ret = "";
		for(String id : ids.split(",")){
			try {
				if(Strings.isEmpty(ret)){
					ret = enumManagerNew.getCtpEnumItem(Long.valueOf(id)).getShowvalue();
				} else {
					ret += "," + enumManagerNew.getCtpEnumItem(Long.valueOf(id)).getShowvalue();
				}
			} catch (NumberFormatException | BusinessException e) {
				// TODO Auto-generated catch block
				log.error("##强生客开: id=" + id + "获取枚举名称异常", e);
			}
		}
		return ret;
	}
	
	@Override
	@AjaxAccess
	public List<Map> getDifferentField(String formId, String masterId) {
		// TODO Auto-generated method stub
		FormDataMasterBean toData = null;
		FormDataMasterBean fromData = null;
		List<Map> retList = new ArrayList<Map>();
		List<Long> sonList = new ArrayList<Long>();
		List<Map<String, Object>> hasSonList = new ArrayList<Map<String,Object>>();
		try {
			FormBean baseBean = null;
			FormBean formBean = null;
			String codes[] = Constants.seepPTCode.split(",");
			for(String code: codes){
				if(!code.contains("_")){
					formBean = formApi4Cap4.getFormByFormCode(code+"_1");
					if(formBean != null &&
							formId.equals(formBean.getId().toString())){
						baseBean = formApi4Cap4.getFormByFormCode(code+"_3");
						break;
					}
				}
			}
			if(formBean == null || baseBean == null){
				return null;
			}
			
			List<CAPFormRelationRecord> relationList = cap4FormRelationRecordDAO.selectRecordByFormMasterDataId(Long.valueOf(masterId));
			List<Map> fieldRelationList = new ArrayList<Map>();
			if(CollectionUtils.isNotEmpty(relationList)){
				Long relationShipId = relationList.get(0).getRelationShipId();
				CAPFormBusinessRelation relationPO = cap4FormBusinessRelationDAO.selectById(relationShipId);
				Map params = JSONUtil.parseJSONString(relationPO.getActionInfo(), Map.class);
				List<JSONObject> mapList = JSONUtil.parseJSONString(params.get("relationMapList").toString(), List.class);
				for(JSONObject obj: mapList){
					String str = JSONUtil.parseJSONString(JSONUtil.toJSONString(obj), Map.class).get("relationFieldList").toString();
					List<JSONObject> fieldList = JSONUtil.parseJSONString(str, List.class);
					for(JSONObject relate: fieldList){
						fieldRelationList.add(JSONUtil.parseJSONString(JSONUtil.toJSONString(relate), Map.class));
					}
				}
				for(CAPFormRelationRecord relation: relationList){
					if(relation.getToFormId().equals(baseBean.getId())
							&& relationShipId.equals(relation.getRelationShipId())){//有报错
						if(relation.getFromSubdataId() == null){
							toData = formApi4Cap4.findDataById(relation.getToMasterDataId(), baseBean, null);
							fromData = formApi4Cap4.findDataById(relation.getFromMasterDataId(), formBean, null);
						} else {
							sonList.add(relation.getFromSubdataId());
						}
					}
				}
				//获取表单自定义控件对应关系
				for(FormFieldBean source: formBean.getAllFieldBeans()){
					if("5550438035101852361".equals(source.getInputType())){
						for(FormFieldBean target: baseBean.getAllFieldBeans()){
							if("5550438035101852361".equals(target.getInputType())
									&& target.getDisplay().equals(source.getDisplay())
									&& target.getOwnerTableDisplay().equals(source.getOwnerTableDisplay())
									&& target.isMasterField() == source.isMasterField()){
								Map<String, String> customMap = new HashMap<String, String>();
								customMap.put(source.getName(), target.getName());
								fieldRelationList.add(customMap);
							}
						}
					}
				}
				for(Map map: fieldRelationList){
					String formField = map.keySet().iterator().next().toString();
					String toField = ParamUtil.getString(map, formField);
					FormFieldBean field = formBean.getFieldBeanByName(formField);
					/********** 主表字段比对 **************/
					if(field.isMasterField()){
						if(null == fromData.getFieldValue(formField)){
							if(null != toData.getFieldValue(toField)){
								try {
									Map ret = getDiferentMap(field, toData.getFieldValue(toField), null);
									retList.add(ret);
								} catch (Exception e) {
									// TODO Auto-generated catch block
									log.error("##强生客开: ", e);
									WordInjectionCtrl a;
									continue;
								}
							}
						} else if(!fromData.getFieldValue(formField).equals(toData.getFieldValue(toField))){
							try {
								Map ret = getDiferentMap(field, toData.getFieldValue(toField), null);
								retList.add(ret);
							} catch (Exception e) {
								// TODO Auto-generated catch block
								log.error("##强生客开: ", e);
								continue;
							}
						}
					} else {
						/********** 从表字段比对 **************/
						for(Long sonId: sonList){
							Map<String, List<FormDataSubBean>> sonMap = fromData.getSubTables();
							for(String key: sonMap.keySet()){
								for(FormDataSubBean dataSubBean: sonMap.get(key)){
									if(dataSubBean.getId().equals(sonId)){
										String displayName = dataSubBean.getFormTable().getDisplay();
										for(FormTableBean toSubTable : baseBean.getSubTableBean()){
											if(toSubTable.getDisplay().equals(displayName)){
												List<FormDataSubBean> toSubDataList = toData.getSubData(toSubTable.getTableName());
												for(FormDataSubBean toDataSubBean: toSubDataList){
													int index = formBean.getSubTableBean().indexOf(dataSubBean.getFormTable());
													if(toSubTable.getFieldBeanByDisplay("隐藏数字_" + toSubTable.getDisplay()) != null){
														if(!toDataSubBean.getFieldValue(toSubTable.getFieldBeanByDisplay("隐藏数字_" + toSubTable.getDisplay()).getName())
																.equals(dataSubBean.getFieldValue(dataSubBean.getFormTable().getFieldBeanByDisplay("隐藏数字_" 
																			+ dataSubBean.getFormTable().getDisplay()).getName()))){
															continue;
														}
													} else {
														if(sonMap.get(key).size() != 1
																&& toSubDataList.size() != 1){
															continue;
														}
													}
													Map<String, Object> hasMap = new HashMap<String, Object>();
													hasMap.put("table", toSubTable.getTableName());
													hasMap.put("sonId", toDataSubBean.getId());
													hasSonList.add(hasMap);
													
													if(null == dataSubBean.getFieldValue(formField)){
														if(null != toDataSubBean.getFieldValue(toField)){
															try {
																Map ret = getDiferentMap(field, 
																		toDataSubBean.getFieldValue(toField), dataSubBean.getId());
																retList.add(ret);
															} catch (Exception e) {
																// TODO Auto-generated catch block
																log.error("##强生客开: ", e);
															}
														}
													} else if(!dataSubBean.getFieldValue(formField).equals(toDataSubBean.getFieldValue(toField))){
														try {
															Map ret = getDiferentMap(field, 
																	toDataSubBean.getFieldValue(toField), dataSubBean.getId());
															retList.add(ret);
														} catch (Exception e) {
															// TODO Auto-generated catch block
															log.error("##强生客开: ", e);
														}
													}
													break;
												}
												break;
											}
										}
									}
								}
							}
						}
					}
				}
			}
			if(fromData != null){
				//行新增、修改判断
				Map<String, List<FormDataSubBean>> sonMap = fromData.getSubTables();
				for(String key: sonMap.keySet()){
					for(FormDataSubBean dataSubBean: sonMap.get(key)){
						int index = formBean.getSubTableBean().indexOf(dataSubBean.getFormTable());
						String tableDisplay = dataSubBean.getFormTable().getDisplay();
						if(dataSubBean.getFormTable().getFieldBeanByDisplay("比对_" + tableDisplay) !=null){
							if(!sonList.contains(dataSubBean.getId())){
								Map ret = new HashMap();
								ret.put("value", "<span style='color: red'>新增</span>");
								ret.put("find", "DIV .cap4-select__browse");
								ret.put("select", dataSubBean.getFormTable().getFieldBeanByDisplay("比对_" + tableDisplay).getName() + "_" + dataSubBean.getId().toString() + "_id");
								retList.add(ret);
							} else {
								boolean update= false;
								for(Map map: retList){
									if(map.get("select").toString().endsWith("_" + dataSubBean.getId() + "_id")){
										update = true;
										break;
									}
								}
								if(update){
									Map ret = new HashMap();
									ret.put("value", "<span style='color: red'>修改</span>");
									ret.put("find", "DIV .cap4-select__browse");
									ret.put("select", dataSubBean.getFormTable().getFieldBeanByDisplay("比对_" + tableDisplay).getName() + "_" + dataSubBean.getId().toString() + "_id");
									retList.add(ret);
								}
							}
						}
					}
				}
			}
			//获取删除行
			for(FormTableBean toSubTable : baseBean.getSubTableBean()){//有报错
				List<FormDataSubBean> toSubDataList = toData.getSubData(toSubTable.getTableName());
//				int index = baseBean.getSubTableBean().indexOf(toSubTable);
				String tableDisplay = toSubTable.getDisplay();
				for(FormDataSubBean toDataSubBean: toSubDataList){
					Map<String, Object> hasMap = new HashMap<String, Object>();
					hasMap.put("table", toSubTable.getTableName());
					hasMap.put("sonId", toDataSubBean.getId());
					if(!hasSonList.contains(hasMap)){
						FormTableBean fromSubTable = null;//formBean.getSubTableBean().get(index);
						for(FormTableBean subTable:formBean.getSubTableBean()){
							if(subTable.getDisplay().equals(subTable.getDisplay())){
								fromSubTable = subTable;
								break;
							}
						}
						Map<String, String> retMap = new HashMap();
						for(Map map: fieldRelationList){
							String formField = map.keySet().iterator().next().toString();
							String toField = ParamUtil.getString(map, formField);
							FormFieldBean field = baseBean.getFieldBeanByName(toField);
							/********** 从表字段比对 **************/
							if(!field.isMasterField()
									&& field.getOwnerTableDisplay().equals(fromSubTable.getDisplay())){
								if("5550438035101852361".equals(field.getInputType())){
									if(toDataSubBean.getFieldValue(toField) == null){
										retMap.put(formField, "");
									} else {
										retMap.put(formField, getEnumShowValue(toDataSubBean.getFieldValue(toField).toString()));
									}
								} else {
									Object[] obj = field.getDisplayValue(toDataSubBean.getFieldValue(toField), true);
									retMap.put(formField, obj[1].toString());
								}
							}
						}
						if(fromSubTable.getFieldBeanByDisplay("比对_" + tableDisplay) !=null){
							retMap.put(fromSubTable.getFieldBeanByDisplay("比对_" + tableDisplay).getName(), "删除");
						} else {
							continue;
						}
						if(!retMap.isEmpty()){
							retMap.put("front", fromSubTable.getFrontTableName());
							retMap.put("table", fromSubTable.getTableName());
							retMap.put("sonId", toDataSubBean.getId().toString());
							retList.add(retMap);
						}
					}
				}
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("##强生客开: ", e);
			return null;
		}
		return retList;
	}

	private Map getDiferentMap(FormFieldBean field, 
			Object toObj, Long subId) throws Exception {
		Map ret = new HashMap();
		if(null == toObj){
			if("5550438035101852361".equals(field.getInputType())){
				if(field.isMasterField()){
					ret.put("select", field.getName() + "_id");
				} else {
					ret.put("select", field.getName() + "_" + subId.toString() + "_id");
				}
				ret.put("find", "DIV .cap4-people__browse");
				ret.put("value", "<span style='color: red'>(空)</span>");
				return ret;
			}
			ret.put("value", "<span style='color: red'>(空)</span>");
		} else {
			String display = null;
			if("5550438035101852361".equals(field.getInputType())){
				display = getEnumShowValue(toObj.toString());
				if(field.isMasterField()){
					ret.put("select", field.getName() + "_id");
				} else {
					ret.put("select", field.getName() + "_" + subId.toString() + "_id");
				}
				ret.put("find", "DIV .cap4-people__browse");
				ret.put("value", "<span style='color: red'>(" + display + ")</span>");
				return ret;
			} else {
				Object[] displayObj = field.getDisplayValue(toObj, true);
				display = displayObj[1].toString();
			}
			ret.put("value", "<span style='color: red'>(" + display + ")</span>");
		}
		
		if(field.getInputType().contains("member")){
			ret.put("find", "DIV .cap4-people__browse");
		} else if(field.getInputType().contains("department")){
			ret.put("find", "DIV .cap4-deparment__browse");
		} else if(field.getInputType().contains("post")){
			ret.put("find", "DIV .cap4-post__browse");
		} else if(field.getInputType().contains("level")){
			ret.put("find", "DIV .cap4-level__browse");
		} else if(field.getInputType().contains("account")){
			ret.put("find", "DIV .cap4-account__browse");
		} else if(field.getInputType().equals("textarea")){
			ret.put("find", "DIV .cap4-textarea__browse");
		} else if(field.getInputType().equals("text")){
			if("VARCHAR".equals(field.getFieldType())){
				ret.put("find", "SPAN");
			} else if("DECIMAL".equals(field.getFieldType())){
				ret.put("find", "DIV .cap4-number__browse");
			} else {
				ret.put("find", "SPAN");
			}
		} else if(field.getInputType().equals("select")){
			ret.put("find", "DIV .cap4-select__browse");
		} else if(field.getInputType().equals("radio")){
			ret.put("find", "DIV .cap4-radio__browse");
		} else if(field.getInputType().equals("checkbox")){
			ret.put("find", "DIV .cap4-checkbox__browse");
		} else if(field.getInputType().equals("number")){
			ret.put("find", "DIV .cap4-number__browse");
		} else if(field.getInputType().equals("datetime")){
			ret.put("find", "DIV .cap4-datetime__browse");
		} else if(field.getInputType().equals("date")){
			ret.put("find", "DIV .cap4-date__browse");
		} else {
			log.info("##强生客开: 未配置类型: "+field.getInputType()+" ,不能进行活动报备比对.");
			ret.put("find", "SPAN");
		}
		/*if("VARCHAR".equals(field.getFieldType())){
			if(field.getInputType().contains("member")){
				ret.put("find", "DIV .cap4-people__browse");
			} else if(field.getInputType().contains("department")){
				ret.put("find", "DIV .cap4-deparment__browse");
			} else if(field.getInputType().contains("post")){
				ret.put("find", "DIV .cap4-post__browse");
			} else if(field.getInputType().contains("level")){
				ret.put("find", "DIV .cap4-level__browse");
			} else if(field.getInputType().contains("account")){
				ret.put("find", "DIV .cap4-account__browse");
			} else if(field.getInputType().equals("textarea")){
				ret.put("find", "DIV .cap4-textarea__browse");
			} else if(field.getInputType().equals("text")){
				ret.put("find", "SPAN");
			} else {
				ret.put("find", "SPAN");
			}
		} else if("DECIMAL".equals(field.getFieldType())){
			if(field.getInputType().equals("select")){
				ret.put("find", "DIV .cap4-select__browse");
			} else if(field.getInputType().equals("radio")){
				ret.put("find", "DIV .cap4-radio__browse");
			} else if(field.getInputType().equals("checkbox")){
				ret.put("find", "DIV .cap4-checkbox__browse");
			} else if(field.getInputType().equals("number")){
				ret.put("find", "DIV .cap4-number__browse");
			}
		} else if("TIMESTAMP".equals(field.getFieldType())
				|| "DATETIME".equals(field.getFieldType())){
			if(field.getInputType().equals("datetime")){
				ret.put("find", "DIV .cap4-datetime__browse");
			} else if(field.getInputType().equals("date")){
				ret.put("find", "DIV .cap4-date__browse");
			}
		} else if("TEXTAREA".equals(field.getFieldType())){
			ret.put("find", "DIV .cap4-textarea__browse");
		} else {
			log.info("##强生客开: 未配置类型: "+field.getFieldType()+" ,不能进行活动报备比对.");
			return null;
		}*/
		if(field.isMasterField()){
			ret.put("select", field.getName() + "_id");
		} else {
			ret.put("select", field.getName() + "_" + subId.toString() + "_id");
		}
		return ret;
	}
	
	public Long getEnumItemIdByName(String parentName, String sonName, String subName) throws Exception {
        List<String> vlist = new ArrayList<String>();
        vlist.add(parentName);
        Map condition = new HashMap();
        condition.put("enumNames", vlist);
        condition.put("accountId", Constants.DEFAULT_ACCOUNT_ID);
        condition.put("enumType", 0); 
        List<CtpEnumBean> list = enumManagerNew.findEnumList(condition);
        if (CollectionUtils.isNotEmpty(list)) {
            for (CtpEnumBean enumBean : list) {
                vlist = new ArrayList<String>();
                vlist.add(sonName);
                condition.put("enumType", 0);
                condition.put("parentId", enumBean.getId());
                condition.put("enumNames", vlist);
                List<CtpEnumBean> sonList = enumManagerNew.findEnumList(condition);
                if (CollectionUtils.isNotEmpty(sonList)) {
                    Long parentId = sonList.get(0).getId();
                    if (StringUtil.isEmpty(subName)) {
                        return parentId;
                    } else {
                        for (CtpEnumItem item : enumManagerNew.getCtpEnumItem(sonList.get(0).getId(), 0)) {
                            if (subName.equals(item.getShowvalue())) {
                                return item.getId();
                            }
                        }
                        return null;
                    }
                } else {
                    CtpEnumItem item = null;
                    for (CtpEnumItem it : enumManagerNew.getCtpEnumItem(enumBean.getId(), 0)) {
                        if (sonName.equals(it.getShowvalue())) {
                            item = it;
                            break;
                        }
                    }

                    if (StringUtil.isEmpty(subName)) {
                        return item.getId();
                    } else {
                        for (CtpEnumItem it : enumManagerNew.getChildEnumItems(item.getId())) {
                            if (subName.equals(it.getShowvalue())) {
                                return it.getId();
                            }
                        }
                        return null;
                    }
                }
            }
        }
        return null;
    }
	
	
	@Override
	public String delBaseData(Long formId, List<String> records){
		int ok = 0;
		int error = 0;
		int exp = 0;
		int over = 0;
		for(String toMasterId: records){
			try {
				if(seepDao.validateBaseData(formId, Long.valueOf(toMasterId))){
					if(formApi4Cap4.deleteFormData(Long.valueOf(toMasterId), formId)){
						++ok;
					} else {
						++error;
					}
				} else {
					++over;
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				++ exp;
				log.error("##强生客开: ", e);
			}
		}
		String ret = "你勾选了 " + records.size() + "条,";
		if(ok != 0){
			ret += "成功删除 " + ok + " 条";
		}
		if(error != 0){
			if(Strings.isNotEmpty(ret)){
				ret += ",";
			}
			ret += "删除失败 " + error + " 条";
		}
		if(exp != 0){
			if(Strings.isNotEmpty(ret)){
				ret += ",";
			}
			ret += "删除时出现异常 " + exp + " 条";
		}
		if(over != 0){
			if(Strings.isNotEmpty(ret)){
				ret += ",";
			}
			ret += "其中被引用数据 " + over + " 条,不能删除";
		}
		if(Strings.isNotEmpty(ret)){
			ret += "!";
		}
		return ret;
	}
	
	public void setEnumManagerNew(EnumManager enumManagerNew) {
		this.enumManagerNew = enumManagerNew;
	}

	public void setFormApi4Cap4(FormApi4Cap4 formApi4Cap4) {
		this.formApi4Cap4 = formApi4Cap4;
	}

	public void setCap4FormRelationRecordDAO(
			CAP4FormRelationRecordDAO cap4FormRelationRecordDAO) {
		this.cap4FormRelationRecordDAO = cap4FormRelationRecordDAO;
	}

	public void setCap4FormBusinessRelationDAO(
			CAP4FormBusinessRelationDAO cap4FormBusinessRelationDAO) {
		this.cap4FormBusinessRelationDAO = cap4FormBusinessRelationDAO;
	}

	public void setCap4FormBusinessRelationManager(
			CAP4FormBusinessRelationManager cap4FormBusinessRelationManager) {
		this.cap4FormBusinessRelationManager = cap4FormBusinessRelationManager;
	}

	public void setOrgManager(OrgManager orgManager) {
		this.orgManager = orgManager;
	}

	public void setSeepDao(SeepDao seepDao) {
		this.seepDao = seepDao;
	}
}
